#ifndef _SCENE_ENGINE_H
#define _SCENE_ENGINE_H

#include "cocos2d.h"

class SceneEngine
{
private:
	//define some template for GUI
	static const int PARAM_TEMPLATE			= 0;
	static const int PARAM_X				= 1;
	static const int PARAM_Y				= 2;
	static const int PARAM_W				= 3;
	static const int PARAM_H				= 4;
	static const int PARAM_VISIBLE			= 5;
	//for spriteBases
	static const int PARAM_SPRITE_ID		= 3;
	static const int PARAM_MODULE_ID		= 4;
	static const int PARAM_ANIM_ID			= 6;
	static const int PARAM_ANIM_COUNT		= 7;
	static const int PARAM_DELAY			= 9;
	//for spriteMove
	static const int PARAM_DES_X			= 6;
	static const int PARAM_DES_Y			= 7;
	static const int PARAM_JUMP_STEP		= 8;	
	//for Button
	static const int PARAM_MODULE_SELECT_ID	= 6;
	//for stringBases
	static const int PARAM_FONT_ID			= 3;
	static const int PARAM_TEXT_ID			= 4;
	static const int PARAM_HALIGN			= 6;
	static const int PARAM_VALIGN			= 7;
	static const int PARAM_RECT_W			= 8;
	static const int PARAM_RECT_H			= 9;

	//ProgressTimer
	static const int PARAM_UP_DOWN			= 6;
	static const int PARAM_DIRECTION		= 7;

	//param
	int sceneEngine_template;
	int sceneEngine_x;
	int sceneEngine_y;	
	int sceneEngine_visible;

	int sceneEngine_spriteID;
	int sceneEngine_moduleID;	
	int sceneEngine_module_selectID;	
	int sceneEngine_animID;
	int sceneEngine_animCount;
	int sceneEngine_delay;

	int sceneEngine_des_x;
	int sceneEngine_des_y;
	int sceneEngine_jump_step;

	int sceneEngine_fontID;
	int sceneEngine_textID;
	int sceneEngine_halign;
	int sceneEngine_valign;
	int sceneEngine_rect_w;
	int sceneEngine_rect_h;

	int sceneEngine_up_down;
	int sceneEngine_direction;

	//save all object on screen
	cocos2d::CCArray* objectArray;
	//save all object with button type
	cocos2d::CCArray* buttonArray;
	//save all object with String type
	cocos2d::CCArray* stringArray;
	//save all progressTimer
	cocos2d::CCArray* progressTimerArray;

protected:
	static SceneEngine* instance;

public:
				
	SceneEngine();
	~SceneEngine();
	static SceneEngine* getInstance();

	//get element tag of scene
	int getElementTag( int sceneID, int elementID );
	
	//get tag max of scene );
	int getMaxTag( int sceneID );

	//get tag min
	int getMinTag ( int sceneID );

	//get elementID from tag
	int getElementIDFromTag ( int tag );

	//get properties
	void getSceneElementProperties ( int sceneID, int elementID );

	//get position of element
	//get properties
	cocos2d::CCPoint getElementPosition ( int sceneID, int elementID );

	//get  button
	cocos2d::CCMenuItem* getButton ( int sceneID, int elementID );

	//get object
	cocos2d::CCObject* getElementObject ( int sceneID, int elementID );

	//get size of rectange example: string rect
	cocos2d::CCSize getElementSize ( int sceneID, int elementID );

	//set visible a element
	void setElementVisible( int sceneID, int elementID, bool visible );

	//set position
	void setElementPosition ( int sceneID, int elementID, cocos2d::CCPoint position );

	//set string
	void setElementString( int sceneID, int elementID, char* str );

	void setElementString( int sceneID, int elementID, int stringID );

	void setElementFont( int sceneID, int elementID, int fontID ); 

	//set button enable
	void setButtonEnable(  int sceneID, int elementID, bool enable );

	//set button enable
	void setButtonEnable(  int sceneID, bool enable );

	//set frame for sprite
	void setSpriteFrame( int sceneID, int elementID, int spriteID, int frameID );

	//set anim for sprite
	void setSpriteAnim( int sceneID, int elementID, int spriteID, int animID );

	//set percent of progress timer
	void setPercentProgress ( int sceneID, int elementID, int percent );
		
	// open a element
	void openElementScene( cocos2d::CCLayer* layer, int sceneID, int elementID );

	/*init all element of level and add on layer
	must use closeScene() when init a scen to remove all object in last scene
	*/
	void openScene( cocos2d::CCLayer* layer, int sceneID, bool removeAlLastScene );

	//open scene with remove all last scene
	void openScene( cocos2d::CCLayer* layer, int sceneID );
	
	//close scene// remove all object in objectArray 
	void closeScene();

	//remove a element of scene 
	void removeElement( cocos2d::CCLayer* layer, int sceneID, int elementID );

	//remove a scene
	void removeScene( cocos2d::CCLayer* layer, int sceneID );
		
};
#endif